package com.yange.accountbook.ui.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yange.accountbook.R
import com.yange.accountbook.entity.AccountDetailEntity
import com.yange.accountbook.utils.StringUtils
import com.yange.accountbook.utils.image.loadCircleImg

class DetailListTwoAdapter :
    BaseQuickAdapter<AccountDetailEntity.DaysDTO.RecordsDTO, BaseViewHolder>(R.layout.item_detail_two_layout) {
    override fun convert(holder: BaseViewHolder, item: AccountDetailEntity.DaysDTO.RecordsDTO) {
        holder.setText(R.id.tv_title, item.name)
        holder.setText(R.id.tv_account, item.accountName)
        holder.setText(R.id.tv_fromName, item.fromName)
        var image = holder.getView<ImageView>(R.id.iv_book_icon)
        context.loadCircleImg(image, item.icon)

        if (item.type.toString().equals("OUT")) {
            holder.setText(R.id.tv_money, "-" + StringUtils.getNoMoreThanTwoDigits(item.money))
        } else {
            holder.setText(R.id.tv_money, "+" + StringUtils.getNoMoreThanTwoDigits(item.money))
        }
    }
}